<?php

namespace Admin\Controller;

use Think\Controller;

class LoginController extends Controller
{
    public function index()
    {
        $admin = D('admin');
        if (IS_POST) {
            if ($admin->create($_POST, 4)) {
                if ($admin->login()) {
                    $this->success('登录成功，跳转中...', U('Index/index'));
                } else {
                    $this->error('用户名或密码错误');
                }
                return;
            } else {
                $this->error($admin->getError());
            }
        }
        if (session('id')) {
            $this->error('你已经登录该系统，请勿重复登录！', U('Index/index'));
        } else {
            $this->display('login');
        }
    }

    //验证码
    public function Verify()
    {
        $Verify = new \Think\Verify();
        $Verify->fontSize = 30;
        $Verify->length = 4;
        $Verify->useNoise = true;
        $Verify->entry();
    }
}